﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Desktop.SHCMPService;
using MahApps.Metro.Controls;

namespace Desktop
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow  
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            try
            {
                SHCMPService.SHCMPServiceSoapClient webseService = new SHCMPServiceSoapClient();
                string ret = webseService.Login(UserNameBox.Text, PasswordBox.Password);
                if (ret.Contains("成功"))
                {
                    ret = ret.Replace("成功", "");
                    
                     
                    Application.Current.Properties["PersonGuid"] = ret;
                    SecondWindow secondWindow = new SecondWindow();
                    secondWindow.Show();
                    this.Close();
                }
                else if (ret.Contains("失败"))
                {
                    MessageBox.Show("您的账号或密码错误，请重新输入。");
                }
                else
                {
                    MessageBox.Show("程序出错，请联系管理员。");

                }
                
            }
            catch (Exception ex)
            {
                 MessageBox.Show("程序异常，请联系管理员。");
            }

        }
    }
}
